# -*- coding: utf-8 -*-
"""
TG下拉选择框组件 - TgComboBox
下拉选择组件
"""
from PySide6.QtWidgets import QComboBox
from ...style_manager import StyleManager


class TgComboBox(QComboBox):
    """TG下拉选择框"""
    
    def __init__(self, parent=None):
        super().__init__(parent)
        # 初始化TG组件属性
        self._component_name = self.__class__.__name__
        self._is_initialized = False
        self._style_applied = False
        self._theme = 'default'
        self._size_hint = 'medium'
        
        # 初始化组件
        self.initialize()
    
    @property
    def component_name(self):
        """获取组件名称"""
        return self._component_name
    
    @property
    def is_initialized(self):
        """检查组件是否已初始化"""
        return self._is_initialized
    
    @property
    def style_applied(self):
        """检查样式是否已应用"""
        return self._style_applied
    
    def setup_ui(self):
        """设置用户界面"""
        # QComboBox的基本设置已在__init__中完成
        pass
    
    def apply_style(self):
        """应用样式"""
        self.setStyleSheet(f"""
            QComboBox {{
                font-size: {StyleManager.FONT_SIZES['normal']};
                padding: {StyleManager.SPACING['sm']};
                border: 1px solid {StyleManager.COLORS['border']};
                border-radius: {StyleManager.BORDER_RADIUS['small']};
                background-color: {StyleManager.COLORS['background']};
                min-width: 120px;
            }}
            QComboBox:focus {{
                border: 2px solid {StyleManager.COLORS['primary']};
            }}
            QComboBox::drop-down {{
                border: none;
                width: 20px;
            }}
            QComboBox::down-arrow {{
                image: none;
                border: 2px solid {StyleManager.COLORS['text_secondary']};
                width: 6px;
                height: 6px;
                border-top: none;
                border-left: none;
                margin-right: 5px;
            }}
        """)
        self._style_applied = True
    
    def initialize(self):
        """初始化组件"""
        if not self._is_initialized:
            self.setup_ui()
            self.apply_style()
            self._is_initialized = True
            self._style_applied = True 